﻿<System.Serializable()> Public Class Package
    Private Ser As New Serializer
    Private M_List As New List(Of FileItem)
    Private M_Stor As New Storage
    Public Event Update()

    Public Sub Add(ByVal Source As String)
        M_List.Add(New FileItem(Source))
        RaiseEvent Update()
    End Sub
    Public Sub Remove(ByVal Name As String)
        For c = 0 To M_List.Count - 1
            Dim f As FileItem = M_List.ElementAt(c)
            If f.Filename.ToUpper = Name.ToUpper Then
                M_List.RemoveAt(c)
                RaiseEvent Update()
                Exit For
            End If
        Next
    End Sub
    Public ReadOnly Property Items() As FileItem()
        Get
            Return M_List.ToArray
        End Get
    End Property
    Public Sub Save(ByVal Path As String)
        Ser.SerializeToFile(Of List(Of FileItem))(Path & ".Sa", M_List)
        Ser.SerializeToFile(Of Storage)(Path & ".Sb", M_Stor)

    End Sub
    Public Sub Load(ByVal Path As String)
        M_List = Ser.DeserializeFromFile(Of List(Of FileItem))(Path & ".Sa")
        M_Stor = Ser.DeserializeFromFile(Of Storage)(Path & ".Sb")
        RaiseEvent Update()
    End Sub
    Public Property Destination() As String
        Get
            Return M_Stor.Destination
        End Get
        Set(ByVal value As String)
            M_Stor.Destination = value
        End Set
    End Property
End Class
<System.Serializable()> Public Class Storage
    Private m_Dest As String
    Public Property Destination() As String
        Get
            Return m_Dest
        End Get
        Set(ByVal value As String)
            m_Dest = value
        End Set
    End Property
End Class
<System.Serializable()> Public Class FileItem
    Private m_File As String
    Private m_Path As String
    Private m_FileName As String
    Private m_Destination As String
    Public Property File() As String
        Get
            Return m_File
        End Get
        Set(ByVal value As String)
            m_File = value
        End Set
    End Property
    Public Property Path() As String
        Get
            Return m_Path
        End Get
        Set(ByVal value As String)
            m_Path = value
        End Set
    End Property
    Public Property Destination() As String
        Get
            Return m_Destination
        End Get
        Set(ByVal value As String)
            m_Destination = value
        End Set
    End Property
    Public Property Filename() As String
        Get
            Return m_FileName
        End Get
        Set(ByVal value As String)
            m_FileName = value
        End Set
    End Property
    Public Sub New(ByVal Source As String)
        m_File = Source
        m_FileName = IO.Path.GetFileName(m_File)
        m_Path = IO.Path.GetDirectoryName(m_File)
    End Sub
End Class
